<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link href="${ctxPath}/css/bootstrap.min.css" rel="stylesheet">
    <script src="${ctxPath}/js/jquery-3.2.1.min.js"></script>
    <script src="${ctxPath}/js/bootstrap.min.js"></script>


</head>
<body>
<!--<h1>系统名称：${username}</h1>-->
<h1>登录页</h1>
<form action="${ctxPath}/login/logindo">
    账户名<input type="text" id="username" name="username" value=""><br/>
    密  码<input type="password" id="password" name="password" value=""><br/>
<!-- <button type="submit">提交</button>-->
    <button  onclick="submitLog()" type="submit">ajax方法登录</button>
</form>

</body>
</html>

<script>
    function submitLog() {
        var username = $("#username").val();
        var password = $("#password").val();
        var url="${ctxPath}/main";
        $.ajax({
            type: "post",
            url: url,
            data: {"username": username,"password":password},
            success:function (data) {
                console.log(data);
                if(data.length>1)
                    location.href="${ctxPath}/main";
            },
            error:function (msg) {
                console.log(msg);
            }
        });
    }


</script>